package com.ict.dataprocess;

import java.io.IOException;
import java.util.Arrays;

import org.apache.log4j.Logger;

import com.ict.config.Config;
import com.ict.utils.ConnMQUtil;
import com.ict.utils.ConnRedisUtil;
import com.rabbitmq.client.ConsumerCancelledException;
import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.ShutdownSignalException;

import team.iOceanPlus.PB.Target;

public class DelReceiveMainMQThread extends Thread {
	

	public void run() {
		while (true) {
			
				
				ConnMQUtil connMQUtil = new ConnMQUtil();
				try {
					QueueingConsumer.Delivery delivery = connMQUtil.recv("topic", Config.recvExChangeName, Config.forwardRoutingKeys, "xgs_tap_by_tlc");
					String message = new String(delivery.getBody());
					byte[] bytmessage = delivery.getBody();
					connMQUtil.send("topic", Config.sendExChangeName,  Config.forwardRoutingKeys[0], null, bytmessage);
					//ConnMQUtil.recvChannel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
				} catch (ShutdownSignalException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (ConsumerCancelledException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			

		}
	}

}
